package com.lms.netty.codec;

import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.util.CharsetUtil;

import java.util.concurrent.TimeUnit;

/**
 * @Author: 李孟帅
 * @CreateTime: 2020-06-16 10:16
 * @Description: 数据处理类
 */
public class NettyServerHandler extends SimpleChannelInboundHandler<Long> {


    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        System.out.println(cause.getMessage());
        ctx.close();
    }

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, Long msg) throws Exception {
        System.out.println(this+"    "+Thread.currentThread().getName()+"   "+Thread.currentThread());
        System.out.println("从客户端"+ctx.channel().remoteAddress()+"读取到long:"+msg);
    }
}
